<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>


<html>
<head>
    <script type="text/javascript">
        var currPrice;
        function checkPrice() {
            if ($("#type").is(":checked")) {
//                $("#price").attr("readonly", true);
                $("#price").val(currPrice + 1);
            } else {
                $("#price").val(currPrice - 1);
//                $("#price").attr("readonly", false);
            }
        }
        $(document).ready(function () {
            $("#code").on("change", function () {
                $.get("${ctx}/getStock", {code: $(this).children('option:selected').val() }, function (data) {
                    if (data != null) {
                        currPrice = data.price;
                        $("#price").val(data.price);
                        $("#stockName").text(data.name);
                        $("#stockCode").val(data.code);
                        $("#stockVolume").val(data.volume);
                        checkPrice();

                    }
                });
            });

            $("#type").on("click", function () {
                checkPrice();
            });
        });
    </script>
</head>
<body>

<!-- content S -->
<div id="content">
    <div class="siteWidth">

        <%--<ul class="wizard-steps">
            <li class="step1">
                <span class="step">1</span>
                <span class="title">选择交易股票</span>
            </li>

            <li class="step2">
                <span class="step">2</span>
                <span class="title">选择交易类型</span>
            </li>

            <li class="step3">
                <span class="step">3</span>
                <span class="title">填写相关信息</span>
            </li>

            <li class="step4">
                <span class="step">4</span>
                <span class="title">提交或者重置</span>
            </li>
            <div class="wizard-line">

            </div>
        </ul>--%>

        <div class="notemessage">
            ${not empty message ? message : ''}
        </div>

        <form id="tradeForm" action="${ctx}/trade/save" method="post" class="form-trade">
            <h1 class="trade-tt blue c-white">股票交易</h1>

            <div class="g-form g-forms2 fl">
                <label for="trader" class="c-blue">交易人</label>
                <select class="form-control2" name="trader" id="trader" multiple="multiple">
                    <c:forEach items="${traders}" var="trader">
                        <option value="${trader.code}">${trader.name}</option>
                    </c:forEach>
                </select>
            </div>

            <div class="g-forms fl">
                <div class="g-form g-form1">
                    <label for="code" class="c-blue">股票代码</label>
                    <select class="form-control" name="code" id="code" multiple="multiple">
                        <c:forEach items="${stocks}" var="stock">
                            <option value="${stock.code}">${stock.name}</option>
                        </c:forEach>
                    </select>
                </div>

                <div class="g-form g-form2">
                    <label for="type">
                        交易类型
                    </label>
                    <input id="type" name="type" value="B" checked="checked" type="checkbox"
                           class="ace ace-switch ace-switch-5">
                    <span class="lbl"></span>

                </div>

                <div class="g-form g-form3">
                    <label for="price" class="c-blue">股价</label>
                    <input type="text" name="price" id="price" readonly/><br/>

                    <label for="tradeCount" class="c-blue">交易数量</label>
                    <input type="text" name="tradeCount" id="tradeCount"/><br/>

                    <%--<label for="trader" class="c-blue">交易人代码</label>
                    <input type="text" name="trader" id="trader"/>--%>
                </div>


                <div class="g-form g-form4">
                    <button id="tradeSubmit" class="btn-y"><i class="icon-ok"></i> 提 交</button>
                </div>
            </div>
            <div class="clear"></div>
        </form>

        <%--<div class="g-stockinfo">
            <h3 class="sitt">股票基础信息</h3>

            <div class="g-stocks">
                <button id="stockName" class="active"></button>
            </div>
            <div class="g-stockdetail">
                <div class="f-fl">
                    <label for="stockCode" class="c-blue">股票代码</label><br/>
                    <input type="text" name="stockCode" id="stockCode" disabled/><br/>
                </div>
                <div class="f-fr">
                    <label for="stockVolume" class="c-blue">发行总量</label><br/>
                    <input type="text" name="stockVolume" id="stockVolume" disabled/><br/>
                </div>
                <div class="clear"></div>
                <label for="company" class="c-blue">公司动态</label><br/>
                <textarea name="company" id="company"></textarea>
            </div>
            <div class="g-stockconfirm">
                <button class="btn-y"><i class="icon-ok"></i> 提 交</button>
                <button class="btn-n"><i class="icon-remove"></i> 重 置</button>
            </div>
        </div>--%>

    </div>
    <!-- siteWidth E -->
</div>
<!-- content E -->

</body>
</html>
